<!DOCTYPE html>
<html>
<body>
<a role="link" aria-expanded="false" id="toggle" href="#">Toggle</a>
<div id="toggleText">
  Lorem ipsum dolor sit amet, consectetur adipiscing elit.
  <a href="#">Cras pretium sed ante <span>ut interdum.</span></a>
</div>
</div>
<script>
  const toggleText = document.getElementById('toggleText');
  const toggleLink = document.getElementById('toggle');

  function toggle() {
    if (toggleText.style.visibility == 'visible') {
      toggleText.style.visibility = 'hidden';
      toggleLink.setAttribute('aria-expanded', 'false');
    } else {
      toggleText.style.visibility = 'visible';
      toggleLink.setAttribute('aria-expanded', 'true');
    }
  }

  const go_passes = [
    () => toggle(),
    () => toggle(),
  ];

  let current_pass = 0;
  function go() {
    go_passes[current_pass++].call();
    return current_pass < go_passes.length;
  }
</script>
</body>
</html>
